package com.chenxi.vhr.mapper;

import com.chenxi.vhr.bean.BaseDepartment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chenxi.vhr.bean.vo.DepartmentTreeVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Entity com.chenxi.vhr.bean.BaseDepartment
 */
public interface BaseDepartmentMapper extends BaseMapper<BaseDepartment> {

    /**
     * 通过SQL递归查询部门树信息
     * @param parentId
     * @return
     */
    List<DepartmentTreeVo> getChildDeptByParentId(int parentId);

    /*注意：存储函数调用的方法没有返回值*/

    /**
     * 新增部门，在mapper中调用存储过程
     * @param department
     */
    void addDept(BaseDepartment department);

    /**
     * 删除部门，调用存储过程
     * @param department
     * @return
     */
    void deleteDept(BaseDepartment department);

    /**
     * 获取子部门的id集合
     * @param departmentId
     * @return
     */
    @Select(value = "select id from base_department where parent_id = #{departmentId}")
    List<Integer> getChildIdByPId(Integer departmentId);
}




